package com.shujia.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class Code06Rename {
    public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {

        // 在conf对象中添加配置信息
        Configuration conf = new Configuration();
//        conf.set("dfs.replication","2");

        System.setProperty("HADOOP_USER_NAME", "root");
        URI uri = new URI("hdfs://master:9000");
        FileSystem fileSystem = FileSystem.get(uri, conf);
        fileSystem.rename(new Path("/data/ccc.txt"),new Path("/data/ddd.txt"));
        // 关闭连接
        fileSystem.close();
    }
}
